#include <REGX52.H>

void Delayxms(unsigned int delay){	// ms
	unsigned char i, j;
	while(delay--){
	i = 2;
	j = 199;
	do
	{
		while (--j);
	} while (--i);
	}
}


void main(){
	unsigned char LEDnum = 0;
	
		while(1){
			if(P3_1 == 0){
				Delayxms(20);
				while(P3_1 == 0){};
				Delayxms(20);
				
				LEDnum++;
				P2 = ~LEDnum;	
				
			
				}
			
		}

}